/*
 * random.c
 *
 *  Created on: 10 Oct 2012
 *      Author: michael
 */

#include "../../include/shredder.h"

#include <stdlib.h>
#include <string.h>

unsigned char *shredder_create_data(int size, DataType type) {
	unsigned char *data;

	switch(type) {
	case SHREDDER_DATA_ZEROES: {
		data = (unsigned char *)calloc(size, 1);
		break;
	}

	case SHREDDER_DATA_ONES: {
		data = (unsigned char *)malloc(size);
		memset(data, SHREDDER_ALL_ONES, size);
		break;
	}

	case SHREDDER_DATA_RANDOM: {
		unsigned char *data = (unsigned char *)malloc(size);
		for(int i = 0; i < size; i++) {
			srand((unsigned int) rand());
			data[i] = (unsigned char)(rand() % 256);
		}
		break;
	}
	}
	return data;
}
